<template>
  <a-layout class="basic-layout">
    <!-- 顶部导航栏 -->
    <a-layout-header class="layout-header">
      <div class="header-container">
        <!-- Logo区域 -->
        <div class="logo-section" @click="handleGoHome">
          <div class="logo-icon">
            <CodeOutlined />
          </div>
          <h1 class="logo-text">智能应用生成平台</h1>
        </div>

        <!-- 桌面端导航菜单 -->
        <nav class="main-nav">
          <a-menu
            mode="horizontal"
            :selected-keys="selectedKeys"
            class="nav-menu"
            :style="{ borderBottom: 'none' }"
          >
            <a-menu-item key="home" @click="handleGoHome">
              <template #icon><HomeOutlined /></template>
              <span class="nav-text">首页</span>
            </a-menu-item>
            <a-menu-item key="explore" @click="handleExplore">
              <template #icon><AppstoreOutlined /></template>
              <span class="nav-text">应用广场</span>
            </a-menu-item>
            <a-menu-item key="docs" @click="handleDocs">
              <template #icon><BookOutlined /></template>
              <span class="nav-text">开发文档</span>
            </a-menu-item>

            <!-- 管理员功能 -->
            <template v-if="isAdmin">
              <a-menu-divider />
              <a-menu-item key="user-manager" @click="handleUserManager">
                <template #icon><TeamOutlined /></template>
                <span class="nav-text">用户管理</span>
              </a-menu-item>
              <a-menu-item key="app-manager" @click="handleAppManager">
                <template #icon><AppstoreOutlined /></template>
                <span class="nav-text">应用管理</span>
              </a-menu-item>
              <a-menu-item key="chat-history-manager" @click="handleChatHistoryManager">
                <template #icon><MessageOutlined /></template>
                <span class="nav-text">对话历史</span>
              </a-menu-item>
            </template>
          </a-menu>
        </nav>

        <!-- 右侧操作区域 -->
        <div class="header-actions">
          <!-- 移动端菜单按钮 -->
          <a-button
            type="text"
            class="mobile-menu-btn"
            @click="toggleMobileMenu"
            :icon="h(MenuOutlined)"
          />

          <!-- 通知按钮 -->
          <a-badge :count="notificationCount" :dot="notificationCount > 0">
            <a-button type="text" class="action-btn notification-btn" :icon="h(BellOutlined)" />
          </a-badge>

          <!-- 用户信息 -->
          <div v-if="loginUserStore.loginUser.id" class="user-section">
            <a-dropdown placement="bottomRight" :trigger="['click']">
              <div class="user-info">
                <a-avatar :src="loginUserStore.loginUser.userAvatar" :size="32" class="user-avatar">
                  {{ getAvatarText(loginUserStore.loginUser.userName) }}
                </a-avatar>
                <span class="user-name">{{ loginUserStore.loginUser.userName }}</span>
                <DownOutlined class="dropdown-icon" />
              </div>

              <template #overlay>
                <a-menu class="user-dropdown-menu">
                  <a-menu-item key="profile" @click="handleProfile">
                    <template #icon><UserOutlined /></template>
                    个人资料
                  </a-menu-item>
                  <a-menu-divider />
                  <a-menu-item key="logout" @click="handleLogout">
                    <template #icon><LogoutOutlined /></template>
                    退出登录
                  </a-menu-item>
                </a-menu>
              </template>
            </a-dropdown>
          </div>

          <!-- 未登录状态 -->
          <div v-else class="auth-buttons">
            <a-button type="text" @click="handleLogin">登录</a-button>
            <a-button type="primary" @click="handleRegister">注册</a-button>
          </div>
        </div>
      </div>
    </a-layout-header>

    <!-- 主要内容区域 -->
    <a-layout-content class="layout-content">
      <div class="content-container">
        <router-view />
      </div>
    </a-layout-content>

    <!-- 移动端导航抽屉 -->
    <a-drawer
      v-model:open="mobileMenuVisible"
      title="导航菜单"
      placement="left"
      :width="280"
      class="mobile-nav-drawer"
    >
      <div class="mobile-nav-content">
        <!-- 主菜单 -->
        <div class="mobile-nav-section">
          <a-menu :selected-keys="selectedKeys" mode="vertical" class="mobile-menu">
            <a-menu-item key="home" @click="handleMobileMenuClick('home')">
              <template #icon><HomeOutlined /></template>
              首页
            </a-menu-item>
            <a-menu-item key="explore" @click="handleMobileMenuClick('explore')">
              <template #icon><AppstoreOutlined /></template>
              应用广场
            </a-menu-item>
            <a-menu-item key="docs" @click="handleMobileMenuClick('docs')">
              <template #icon><BookOutlined /></template>
              开发文档
            </a-menu-item>
          </a-menu>
        </div>

        <!-- 管理员菜单 -->
        <div v-if="isAdmin" class="mobile-nav-section">
          <a-divider>管理功能</a-divider>
          <a-menu :selected-keys="selectedKeys" mode="vertical" class="mobile-menu admin-menu">
            <a-menu-item key="user-manager" @click="handleMobileMenuClick('user-manager')">
              <template #icon><TeamOutlined /></template>
              用户管理
            </a-menu-item>
            <a-menu-item key="app-manager" @click="handleMobileMenuClick('app-manager')">
              <template #icon><AppstoreOutlined /></template>
              应用管理
            </a-menu-item>
            <a-menu-item
              key="chat-history-manager"
              @click="handleMobileMenuClick('chat-history-manager')"
            >
              <template #icon><MessageOutlined /></template>
              对话历史
            </a-menu-item>
          </a-menu>
        </div>

        <!-- 用户信息区域 -->
        <div v-if="loginUserStore.loginUser.id" class="mobile-user-section">
          <a-divider>用户信息</a-divider>
          <div class="mobile-user-info">
            <a-avatar
              :src="loginUserStore.loginUser.userAvatar"
              :size="40"
              class="mobile-user-avatar"
            >
              {{ getAvatarText(loginUserStore.loginUser.userName) }}
            </a-avatar>
            <div class="mobile-user-details">
              <div class="mobile-user-name">{{ loginUserStore.loginUser.userName }}</div>
              <div class="mobile-user-role">
                {{ loginUserStore.loginUser.userRole === 'admin' ? '管理员' : '普通用户' }}
              </div>
            </div>
          </div>

          <a-menu mode="vertical" class="mobile-menu user-actions">
            <a-menu-item key="profile" @click="handleMobileMenuClick('profile')">
              <template #icon><UserOutlined /></template>
              个人资料
            </a-menu-item>
            <a-menu-item key="settings" @click="handleMobileMenuClick('settings')">
              <template #icon><SettingOutlined /></template>
              设置
            </a-menu-item>
            <a-menu-item key="logout" @click="handleMobileMenuClick('logout')" class="logout-item">
              <template #icon><LogoutOutlined /></template>
              退出登录
            </a-menu-item>
          </a-menu>
        </div>
      </div>
    </a-drawer>

    <!-- 底部 -->
    <a-layout-footer class="layout-footer">
      <div class="footer-container">
        <div class="footer-content">
          <div class="footer-section">
            <h4>产品</h4>
            <ul>
              <li><a href="#">应用生成</a></li>
              <li><a href="#">代码编辑</a></li>
              <li><a href="#">一键部署</a></li>
              <li><a href="#">团队协作</a></li>
            </ul>
          </div>

          <div class="footer-section">
            <h4>开发者</h4>
            <ul>
              <li><a href="#">API 文档</a></li>
              <li><a href="#">SDK 下载</a></li>
              <li><a href="#">开发指南</a></li>
              <li><a href="#">社区论坛</a></li>
            </ul>
          </div>

          <div class="footer-section">
            <h4>支持</h4>
            <ul>
              <li><a href="#">帮助中心</a></li>
              <li><a href="#">联系我们</a></li>
              <li><a href="#">服务状态</a></li>
              <li><a href="#">反馈建议</a></li>
            </ul>
          </div>

          <div class="footer-section">
            <h4>关于</h4>
            <ul>
              <li><a href="#">公司介绍</a></li>
              <li><a href="#">隐私政策</a></li>
              <li><a href="#">服务条款</a></li>
              <li><a href="#">加入我们</a></li>
            </ul>
          </div>
        </div>

        <div class="footer-bottom">
          <div class="copyright">© 2024 智能应用生成平台. All rights reserved.</div>
          <div class="footer-links">
            <a href="#">隐私政策</a>
            <span class="divider">|</span>
            <a href="#">服务条款</a>
            <span class="divider">|</span>
            <a href="#">Cookie 政策</a>
          </div>
        </div>
      </div>
    </a-layout-footer>
  </a-layout>
</template>

<script setup lang="ts">
import { ref, computed, h } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { message } from 'ant-design-vue'
import {
  CodeOutlined,
  HomeOutlined,
  AppstoreOutlined,
  BookOutlined,
  BellOutlined,
  UserOutlined,
  SettingOutlined,
  LogoutOutlined,
  TeamOutlined,
  MenuOutlined,
  MessageOutlined,
  DownOutlined
} from '@ant-design/icons-vue'
import { useLoginUserStore } from '@/stores/loginUser'
import { logout } from '@/api/userController'

const router = useRouter()
const route = useRoute()
const loginUserStore = useLoginUserStore()

// 状态定义
const mobileMenuVisible = ref(false)
const notificationCount = ref(3) // 模拟通知数量

// 当前选中的菜单项
const selectedKeys = computed(() => {
  const path = route.path
  if (path === '/') return ['home']
  if (path.startsWith('/explore')) return ['explore']
  if (path.startsWith('/docs')) return ['docs']
  if (path.startsWith('/admin/user-manager')) return ['user-manager']
  if (path.startsWith('/admin/app-manager')) return ['app-manager']
  if (path.startsWith('/admin/chat-history-manager')) return ['chat-history-manager']
  return []
})

// 是否为管理员
const isAdmin = computed(() => {
  return loginUserStore.loginUser.userRole === 'admin'
})

// 获取头像显示文字
const getAvatarText = (userName?: string) => {
  if (!userName) return 'U'
  // 优先显示中文名字的最后一个字
  const chineseMatch = userName.match(/[一-鿿]/g)
  if (chineseMatch && chineseMatch.length > 0) {
    return chineseMatch[chineseMatch.length - 1]
  }
  // 如果没有中文，显示第一个字符
  return userName.charAt(0).toUpperCase()
}

// 处理函数
const handleGoHome = () => {
  router.push('/')
}

const handleExplore = () => {
  router.push('/explore')
}

const handleDocs = () => {
  router.push('/docs')
}

const handleProfile = () => {
  router.push('/user/edit')
}

const handleMyApps = () => {
  router.push('/')
}

const handleSettings = () => {
  router.push('/settings')
}

const handleUserManager = () => {
  router.push('/admin/user-manager')
}

const handleAppManager = () => {
  router.push('/admin/app-manager')
}

const handleChatHistoryManager = () => {
  router.push('/admin/chat-history-manager')
}

const handleLogin = () => {
  router.push('/user/login')
}

const handleRegister = () => {
  router.push('/user/register')
}

const handleLogout = async () => {
  try {
    await logout()
    loginUserStore.logout()
    message.success('退出登录成功')
    router.push('/user/login')
  } catch (error) {
    console.error('退出登录失败：', error)
    loginUserStore.logout()
    message.warning('退出登录')
    router.push('/user/login')
  }
}

// 移动端菜单处理
const toggleMobileMenu = () => {
  mobileMenuVisible.value = !mobileMenuVisible.value
}

const handleMobileMenuClick = (key: string) => {
  mobileMenuVisible.value = false

  const actions: Record<string, () => void> = {
    home: handleGoHome,
    explore: handleExplore,
    docs: handleDocs,
    'user-manager': handleUserManager,
    'app-manager': handleAppManager,
    'chat-history-manager': handleChatHistoryManager,
    profile: handleProfile,
    settings: handleSettings,
    logout: handleLogout
  }

  const action = actions[key]
  if (action) {
    action()
  }
}
</script>

<style scoped>
/* ===== 基本布局样式 ===== */
.basic-layout {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* ===== 头部导航栏 ===== */
.layout-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0;
  height: 64px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* ===== Logo 区域 ===== */
.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.logo-section:hover {
  transform: translateY(-1px);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-section:hover .logo-icon {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

/* ===== 导航菜单 ===== */
.main-nav {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 600px;
  overflow: hidden; /* 防止菜单溢出 */
}

.nav-menu {
  background: transparent;
  border: none !important;
  display: flex;
  align-items: center;
  height: 64px;
  width: 100%;
  justify-content: center;
  flex-wrap: nowrap; /* 防止菜单换行 */
  overflow-x: auto; /* 在极小屏幕上允许水平滚动 */
  scrollbar-width: none; /* 隐藏滚动条 */
}

.nav-menu::-webkit-scrollbar {
  display: none; /* 隐藏 webkit 滚动条 */
}

.nav-menu :deep(.ant-menu-item) {
  height: 40px;
  line-height: 40px;
  border-radius: 8px;
  margin: 0 6px;
  padding: 0 16px;
  color: #6b7280;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.nav-menu :deep(.ant-menu-item:hover) {
  background: rgba(102, 126, 234, 0.08);
  color: #667eea;
  transform: translateY(-1px);
}

.nav-menu :deep(.ant-menu-item-selected) {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.08) 100%);
  color: #667eea !important;
  font-weight: 600;
}

.nav-menu :deep(.ant-menu-item-selected::after) {
  display: none;
}

.nav-menu :deep(.ant-menu-divider) {
  margin: 8px 12px;
  background: rgba(0, 0, 0, 0.1);
}

/* ===== 右侧操作区域 ===== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: #6b7280;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  align-items: center;
  justify-content: center;
}

.mobile-menu-btn:hover {
  background: rgba(102, 126, 234, 0.08);
  border-color: rgba(102, 126, 234, 0.2);
  color: #667eea;
  transform: translateY(-1px);
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: #6b7280;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:hover {
  background: rgba(102, 126, 234, 0.08);
  border-color: rgba(102, 126, 234, 0.2);
  color: #667eea;
  transform: translateY(-1px);
}

/* ===== 用户信息 ===== */
.user-section {
  position: relative;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}

.user-info:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(102, 126, 234, 0.2);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

.user-avatar {
  flex-shrink: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  border: 2px solid rgba(255, 255, 255, 0.9);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.dropdown-icon {
  font-size: 12px;
  color: #9ca3af;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-info:hover .dropdown-icon {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  min-width: 200px;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
  padding: 8px;
}

.user-dropdown-menu :deep(.ant-menu-item) {
  margin: 2px 0;
  border-radius: 8px;
  height: 40px;
  line-height: 40px;
  padding: 0 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-dropdown-menu :deep(.ant-menu-item:hover) {
  background: rgba(102, 126, 234, 0.08);
  color: #667eea;
}

.user-dropdown-menu :deep(.ant-menu-divider) {
  margin: 8px 0;
  background: rgba(0, 0, 0, 0.06);
}

/* ===== 登录/注册按钮 ===== */
.auth-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-buttons .ant-btn {
  height: 36px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-buttons .ant-btn[type='text'] {
  color: #6b7280;
}

.auth-buttons .ant-btn[type='text']:hover {
  background: rgba(102, 126, 234, 0.08);
  color: #667eea;
}

.auth-buttons .ant-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.auth-buttons .ant-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ===== 主内容区域 ===== */
.layout-content {
  flex: 1;
  min-height: calc(100vh - 64px - 280px);
}

.content-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== 移动端导航 ===== */
.mobile-nav-drawer {
  z-index: 1100;
}

.mobile-nav-drawer :deep(.ant-drawer-body) {
  padding: 0;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.mobile-nav-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.mobile-nav-section {
  padding: 16px 0;
}

.mobile-nav-section:first-child {
  padding-top: 8px;
}

.mobile-menu {
  background: transparent;
  border: none;
}

.mobile-menu .ant-menu-item {
  margin: 2px 16px;
  border-radius: 12px;
  height: 48px;
  line-height: 48px;
  padding: 0 16px;
  color: #4b5563;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu .ant-menu-item:hover {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  transform: translateX(4px);
}

.mobile-menu .ant-menu-item-selected {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea !important;
  font-weight: 600;
}

.mobile-menu.admin-menu .ant-menu-item {
  color: #7c3aed;
}

.mobile-menu.admin-menu .ant-menu-item:hover {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
}

/* 移动端用户信息 */
.mobile-user-section {
  margin-top: auto;
  padding: 16px;
  background: rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  margin-bottom: 16px;
}

.mobile-user-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.mobile-user-details {
  flex: 1;
  min-width: 0;
}

.mobile-user-name {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
}

.mobile-user-role {
  font-size: 12px;
  color: #6b7280;
  padding: 2px 8px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 12px;
  display: inline-block;
}

.mobile-menu.user-actions .ant-menu-item {
  margin: 2px 0;
}

.mobile-menu.user-actions .logout-item {
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.mobile-menu.user-actions .logout-item:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ===== 底部样式 ===== */
.layout-footer {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  color: #d1d5db;
  padding: 48px 0 24px;
  margin-top: 80px;
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px;
  margin-bottom: 32px;
}

.footer-section h4 {
  color: white;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-section li {
  margin-bottom: 8px;
}

.footer-section a {
  color: #9ca3af;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-section a:hover {
  color: #667eea;
  transform: translateX(4px);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid #374151;
}

.copyright {
  color: #9ca3af;
  font-size: 14px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-links a {
  color: #9ca3af;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-links a:hover {
  color: #667eea;
}

.divider {
  color: #4b5563;
}

/* ===== 响应式设计 ===== */
@media (min-width: 1401px) {
  .header-container {
    max-width: 1600px;
    margin: 0 auto;
  }
  
  .main-nav {
    max-width: 700px;
  }
}

@media (max-width: 1400px) {
  .header-container {
    padding: 0 20px;
    gap: 20px;
  }

  .content-container {
    padding: 20px;
  }
}

@media (max-width: 1200px) {
  .header-container {
    gap: 16px;
  }
  
  .main-nav {
    max-width: 500px;
  }
  
  /* 缩小菜单项间距但保留文字 */
  .nav-menu :deep(.ant-menu-item) {
    margin: 0 4px;
    padding: 0 12px;
    font-size: 14px;
  }
}

@media (max-width: 1024px) {
  .logo-text {
    font-size: 16px;
  }

  .main-nav {
    max-width: 400px;
  }
  
  .nav-menu :deep(.ant-menu-item) {
    margin: 0 2px;
    padding: 0 10px;
  }
}

@media (max-width: 900px) {
  .header-container {
    gap: 12px;
  }
  
  .main-nav {
    max-width: 350px;
  }
  
  /* 隐藏导航文字，只显示图标 */
  .nav-text {
    display: none;
  }
  
  .nav-menu :deep(.ant-menu-item) {
    margin: 0 1px;
    padding: 0 8px;
    min-width: 40px;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .logo-text {
    font-size: 14px;
  }
  
  .main-nav {
    max-width: 300px;
  }
  
  .nav-menu :deep(.ant-menu-item) {
    margin: 0;
    padding: 0 6px;
    min-width: 36px;
  }
  
  .header-container {
    padding: 0 16px;
    gap: 8px;
  }
  
  .user-name {
    display: none;
  }
  
  .user-info {
    padding: 4px;
    gap: 4px;
  }
}

@media (max-width: 600px) {
  /* 在600px以下才隐藏主导航，显示移动端菜单 */
  .main-nav {
    display: none;
  }

  .mobile-menu-btn {
    display: flex !important;
  }

  .header-container {
    justify-content: space-between;
    gap: 12px;
  }

  .layout-header {
    height: 56px;
  }

  .header-container {
    padding: 0 16px;
    height: 56px;
  }

  .logo-text {
    display: none;
  }

  .action-btn {
    width: 36px;
    height: 36px;
  }

  .mobile-menu-btn {
    width: 36px;
    height: 36px;
  }

  .content-container {
    padding: 16px;
    min-height: calc(100vh - 56px - 280px);
  }

  .footer-bottom {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 0 12px;
  }

  .header-actions {
    gap: 8px;
  }

  .auth-buttons {
    gap: 6px;
  }

  .auth-buttons .ant-btn {
    padding: 0 12px;
    font-size: 13px;
    height: 32px;
  }

  .content-container {
    padding: 12px;
  }
}

/* ===== 动画效果 ===== */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-nav-drawer :deep(.ant-drawer-content) {
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-dropdown-menu {
  animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 3px;
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}

/* ===== 焦点样式 ===== */
.nav-menu :deep(.ant-menu-item):focus-visible,
.action-btn:focus-visible,
.mobile-menu-btn:focus-visible,
.user-info:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* ===== 高对比度模式支持 ===== */
@media (prefers-contrast: high) {
  .layout-header {
    border-bottom: 2px solid #000;
  }

  .nav-menu :deep(.ant-menu-item) {
    border: 1px solid transparent;
  }

  .nav-menu :deep(.ant-menu-item-selected) {
    border-color: #667eea;
  }
}

/* ===== 减少动画模式支持 ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
</style>
